<template>
    <Modal title="修改密码" v-model="show" :closable="false" :mask-closable="false">
        <el-form ref="mchForm" label-position="right" label-width="120px" :model="mch" :rules="pwdRules">
            <el-form-item label="新登录密码" prop="pwd">
               <el-input size="small"  type="password" v-model="mch.pwd" placeholder="新登录密码" style="width: 240px" />
            </el-form-item>
            <el-form-item label="重复新登录密码" prop="cfpwd">
               <el-input size="small"  type="password" v-model="mch.cfpwd" placeholder="重复新登录密码" style="width: 240px" />
            </el-form-item>
            
        </el-form>
        <div slot="footer">
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" :loading="modalLoading" @click="ok">确定</el-button>
        </div>
    </Modal>
</template>
<script>
export default {
    name: 'CPassword',
    data() {
        return {
            modelShow: true,
            modalLoading: false,
            pwdRules: {

            },
            mch: {
                cfpaypwd: "",
                paypwd: "",
                pwd: "",
                cfpwd: ""
            }

        };
    },
    props: [
        'userId', 'show'
    ],
    mounted: function() {


    },
    methods: {
        ok: function() {

            if (this.mch.pwd != "" && this.mch.pwd != this.mch.cfpwd) {
                this.errorMessage("两次登录密码不一致");
                return;
            }

            var me = this;
            var params={userId:me.userId};
            params['passport']=me.mch.pwd;
            params['cfPassport']=me.mch.cfpwd;
           
            me.$http.post("/sys/merchant/dopwd.action", params).then(response => {
                var body = response;
                if (body.status == 0) {

                    me.$Message.info("操作成功");

                    me.$emit('ok');

                } else {
                    me.errorMessage( body.info);
                }
            }, response => {

            });

        },
        cancel: function() {

            this.$emit('cancel');
        }
    }
}
</script>